package com.curso.examples.spring.aop.aop;

import java.util.Date;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;


@Aspect
public class PersonaAroundAdvice {

	@Around("execution(* com.curso.examples.spring.aop.dao.intf.PersonaDAO.grabar(..))")
	public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
		System.out.println("Init method: " + joinPoint.getSignature().getName());
		Date start = new Date();
		System.out.println("Time before execution: " + start.getTime());
		Object resultado = joinPoint.proceed();
		Date end = new Date();
		System.out.println("Time after execution: " + end.getTime());
		System.out.println("Method performance in: " + (end.getTime() - start.getTime()));
		
		return resultado;
	}

	
}
